﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Macds.Core.Configuration;

namespace Macds.Core.IoC
{
    public class ObjectsConfigurationSection : ConfigurationSection
    {
        [ConfigurationProperty("objects", IsRequired = true),
        ConfigurationCollection(typeof(GenericElementCollection<ObjectElement>), AddItemName = "object", ClearItemsName = "clear", RemoveItemName = "remove")]
        public GenericElementCollection<ObjectElement> Objects
        {
            get { return (GenericElementCollection<ObjectElement>)this["objects"]; }
            set { this["objects"] = value; }
        }

        [ConfigurationProperty("types", IsRequired = false),
        ConfigurationCollection(typeof(GenericElementCollection<ClassElement>), AddItemName = "type", ClearItemsName = "clear", RemoveItemName = "remove")]
        public GenericElementCollection<ClassElement> Types
        {
            get { return (GenericElementCollection<ClassElement>)this["types"]; }
            set { this["types"] = value; }
        }

        public static ObjectsConfigurationSection Load()
        {
            return (ObjectsConfigurationSection)System.Configuration.ConfigurationManager.GetSection("IoC");
        }
    }
}
